﻿using System;
using System.Data;
using System.Collections.Generic;
using DataLib.Common;
using DataLib.Model;

namespace DataLib.BLL
{
	/// <summary>
	/// StorageData
	/// </summary>
	public partial class StorageData
	{
		#region  ExtensionMethod
        /// <summary>
        /// 库存分组查询
        /// </summary>
        /// <param name="startdate"></param>
        /// <param name="enddate"></param>
        /// <param name="strbelong"></param>
        /// <param name="strdis"></param>
        /// <param name="gcode"></param>
        /// <param name="stroageno"></param>
        /// <returns></returns>
        public DataTable getDsByDate(DateTime startdate, DateTime enddate, string strbelong, string strdis, string gcode, string stroageno)
        {
            //DateTime sdate = startdate.AddDays(1).AddSeconds(-1);
            return new DAL.StorageData().getDsByDate(startdate, enddate, strbelong, strdis, gcode, stroageno);
        }
        /// <summary>
        /// 取当前期初净重
        /// </summary>
        /// <param name="goodid"></param>
        /// <returns></returns>
        public decimal GetCurNwt(int goodid)
        {
            decimal startnwt = 0;
            DataTable dt = dal.GetList(1," goodsid= " + goodid.ToString()," StorageData.id desc").Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                startnwt = decimal.Parse(dt.Rows[0]["startnwt"].ToString());
            }
            return startnwt;
        }

        /// <summary>
        /// 根据虚拟Load号取得Load号总重量
        /// </summary>
        /// <param name="vloadnum">虚拟Load号</param>
        /// <param name="flag">0是Load单总重量，否则是已入库总重量</param>
        /// <returns></returns>
        public string GetLoadWeight(string vloadnum, int flag)
        {
            return dal.GetLoadWeight(vloadnum, flag);
        }

        /// <summary>
        /// 根据虚拟Load获取入库所有日期
        /// </summary>
        /// <param name="vLoadNum">虚拟Load号</param>
        /// <param name="flag">0代表正文显示，其他值代表Title，鼠标移上去的提示</param>
        /// <returns></returns>
        public string InStorageDate(string vLoadNum, int flag)
        {
            return dal.InStorageDate(vLoadNum, flag);
        }

              /// <summary>
        /// 取得当前的期末净重
        /// </summary>
        /// <param name="goodsCode"></param>
        /// <param name="strno">库位号</param>
        /// <returns></returns>
        public decimal CurEndNwt(string goodsCode, string strno)
        {
            return dal.CurEndNwt(goodsCode, strno);
        }

                /// <summary>
        /// 获取某段时间内的库存明细
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="strbelong">归属地</param>
        /// <param name="strdis">物理地</param>
        /// <returns></returns>
        public DataTable StorageItemsQuery(string enddate, string bcity, string gcity)
        {

            return dal.StorageItemsQuery(enddate, bcity, gcity);
        }

            /// <summary>
        /// 获取某段时间内的库存明细
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="strbelong">归属地</param>
        /// <param name="strdis">物理地</param>
        /// <returns></returns>
        public DataTable StorageItemsQueryPage(string enddate, string bcity, string gcity, int currpage, int length, out int totalRecord)
        {
            return dal.StorageItemsQueryPage(enddate, bcity, gcity, currpage, length, out totalRecord);
        }

           /// <summary>
        /// 获取某段时间内的库存明细
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="strbelong">归属地</param>
        /// <param name="strdis">物理地</param>
        /// <returns></returns>
        public DataTable GetStorageItemsQuery(string enddate, string bcity, string gcity)
        {
            return dal.GetStorageItemsQuery(enddate, bcity, gcity);
        }
		#endregion  ExtensionMethod
	}
}

